<?php

declare(strict_types=1);

namespace Plugin\Attractions\HaiKang\Controller;

use Common\CommonController;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\GetMapping;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\Swagger\Annotation\HyperfServer;
use Plugin\Attractions\HaiKang\Service\HKDeviceService;

#[HyperfServer(name: 'http')]
#[Controller('attractions/hk/device')]
class HKDeviceController extends CommonController
{

    #[Inject()]
    private HKDeviceService $service;
    #[GetMapping(path: 'listGroups')]
    public function listGroups()
    {
        $params = $this->valid([
            'groupID' => 'string',
            'groupName' => 'string',
            'groupNo' => 'string',
            'parentID' => 'string'
        ], [
            
        ]);
        return $this->success($this->service->groupList($params));
    }

    #[GetMapping(path: 'listDevices')]
    public function listDevices()
    {
        $params = $this->valid([], []);
        return $this->success($this->service->deviceList($params));
    }
    
    #[PostMapping(path: 'syncGroups')]
    public function syncGroup()
    {
        return $this->success($this->service->syncGroups());
    }

    #[PostMapping(path: 'syncDevices')]
    public function syncDevice()
    {
        $params = $this->valid([], []);
        return $this->success($this->service->syncDevices($params));
    }

}